package com.example.service.impl;

import com.example.dao.StuInforDao;
import com.example.entity.PageInfo;
import com.example.entity.Result;
import com.example.entity.StudentFile;
import com.example.entity.StudentInformation;
import com.example.service.StuInforService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
@Slf4j
public class StuInforServiceImpl implements StuInforService {
    @Resource
    StuInforDao stuInforDao;

    @Override
    public String adduStuInfor(StudentInformation studentInformation) throws Exception{
        if(stuInforDao.queryOneStuInfor(studentInformation.getStudentId())!=null){
            //已经上传过信息
            return "信息已经填报过";
        }
        stuInforDao.addStudInfor(studentInformation);
        return studentInformation.getStudentId();
    }

    @Override
    public boolean editStuInfor(StudentInformation studentInformation) {
        return false;
    }

    @Override
    public boolean deleteStuInfor(String id) {
        return false;
    }

    @Override
    public int queryAllStuInforCount(PageInfo pageInfo) {
        return 0;
    }

    @Override
    public List<StudentInformation> queryAllStuInforPage(PageInfo pageInfo) {
        return null;
    }

    @Override
    public String saveFile(StudentFile studentFile) {
        if(stuInforDao.queryOneStudentFile(studentFile.getStu_id()) != null){
            return "文件已上传过";
        }
        stuInforDao.saveFile(studentFile);
        return studentFile.getStu_id();
    }

    @Override
    public Result queryResult(String id) {
        if (id==null){
            log.info("id为空");
        }
        return stuInforDao.queryResult(id);
    }
}
